<!DOCTYPE html>
<html lang="zh-CN">
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <meta name="robots" content="noodp" />
        <title>EtherCAT从会到不会——封包解析（3） - 陈的错题集</title><meta name="Description" content="陈的错题集 - 个人笔记"><meta property="og:title" content="EtherCAT从会到不会——封包解析（3）" />
<meta property="og:description" content="本来还想着起什么名字，但是对比起内容，名字什么的一点都不重要。 最近我又想起要写点什么东西防止最后什么都不剩下。那就从EtherCAT开始吧！" />
<meta property="og:type" content="article" />
<meta property="og:url" content="https://example.com/ethercat_03protocol/" /><meta property="og:image" content="https://example.com/logo.png"/><meta property="article:section" content="posts" />
<meta property="article:published_time" content="2023-08-27T00:09:46+08:00" />
<meta property="article:modified_time" content="2023-08-27T00:09:46+08:00" /><meta property="og:site_name" content="陈的错题集" />
<meta name="twitter:card" content="summary_large_image"/>
<meta name="twitter:image" content="https://example.com/logo.png"/>

<meta name="twitter:title" content="EtherCAT从会到不会——封包解析（3）"/>
<meta name="twitter:description" content="本来还想着起什么名字，但是对比起内容，名字什么的一点都不重要。 最近我又想起要写点什么东西防止最后什么都不剩下。那就从EtherCAT开始吧！"/>
<meta name="application-name" content="陈的错题集">
<meta name="apple-mobile-web-app-title" content="陈的错题集"><meta name="theme-color" content="#ffffff"><meta name="msapplication-TileColor" content="#da532c"><link rel="shortcut icon" type="image/x-icon" href="/favicon.ico" />
        <link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
        <link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png"><link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png"><link rel="mask-icon" href="/safari-pinned-tab.svg" color="#5bbad5"><link rel="manifest" href="/site.webmanifest"><link rel="canonical" href="https://example.com/ethercat_03protocol/" /><link rel="prev" href="https://example.com/redis_01pubsub/" /><link rel="next" href="https://example.com/ethercat_04esi_0d/" /><link rel="stylesheet" href="/css/style.min.css"><link rel="preload" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@6.1.1/css/all.min.css" as="style" onload="this.onload=null;this.rel='stylesheet'">
        <noscript><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@6.1.1/css/all.min.css"></noscript><link rel="preload" href="https://cdn.jsdelivr.net/npm/animate.css@4.1.1/animate.min.css" as="style" onload="this.onload=null;this.rel='stylesheet'">
        <noscript><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/animate.css@4.1.1/animate.min.css"></noscript><script type="application/ld+json">
    {
        "@context": "http://schema.org",
        "@type": "BlogPosting",
        "headline": "EtherCAT从会到不会——封包解析（3）",
        "inLanguage": "zh-CN",
        "mainEntityOfPage": {
            "@type": "WebPage",
            "@id": "https:\/\/example.com\/ethercat_03protocol\/"
        },"image": ["https:\/\/example.com\/images\/Apple-Devices-Preview.png"],"genre": "posts","keywords": "EtherCAT","wordcount":  1807 ,
        "url": "https:\/\/example.com\/ethercat_03protocol\/","datePublished": "2023-08-27T00:09:46+08:00","dateModified": "2023-08-27T00:09:46+08:00","publisher": {
            "@type": "Organization",
            "name": "xxxx","logo": "https:\/\/example.com\/images\/avatar.png"},"author": {
                "@type": "Person",
                "name": "Jacob Chen"
            },"description": ""
    }
    </script></head>
    <body data-header-desktop="fixed" data-header-mobile="auto"><script type="text/javascript">(window.localStorage && localStorage.getItem('theme') ? localStorage.getItem('theme') === 'dark' : ('auto' === 'auto' ? window.matchMedia('(prefers-color-scheme: dark)').matches : 'auto' === 'dark')) && document.body.setAttribute('theme', 'dark');</script>

        <div id="mask"></div><div class="wrapper"><header class="desktop" id="header-desktop">
    <div class="header-wrapper">
        <div class="header-title">
            <a href="/" title="陈的错题集">💻陈的错题集</a>
        </div>
        <div class="menu">
            <div class="menu-inner"><a class="menu-item" href="/posts/"> 📜归档 </a><a class="menu-item" href="/tags/"> 🏷️标签 </a><a class="menu-item" href="/categories/"> 📂分类 </a><a class="menu-item" href="/about/"> ⭐关于 </a><span class="menu-item delimiter"></span><span class="menu-item search" id="search-desktop">
                        <input type="text" placeholder=" " id="search-input-desktop">
                        <a href="javascript:void(0);" class="search-button search-toggle" id="search-toggle-desktop" title="搜索">
                            <i class="fas fa-search fa-fw" aria-hidden="true"></i>
                        </a>
                        <a href="javascript:void(0);" class="search-button search-clear" id="search-clear-desktop" title="清空">
                            <i class="fas fa-times-circle fa-fw" aria-hidden="true"></i>
                        </a>
                        <span class="search-button search-loading" id="search-loading-desktop">
                            <i class="fas fa-spinner fa-fw fa-spin" aria-hidden="true"></i>
                        </span>
                    </span><a href="javascript:void(0);" class="menu-item theme-switch" title="切换主题">
                    <i class="fas fa-adjust fa-fw" aria-hidden="true"></i>
                </a></div>
        </div>
    </div>
</header><header class="mobile" id="header-mobile">
    <div class="header-container">
        <div class="header-wrapper">
            <div class="header-title">
                <a href="/" title="陈的错题集">💻陈的错题集</a>
            </div>
            <div class="menu-toggle" id="menu-toggle-mobile">
                <span></span><span></span><span></span>
            </div>
        </div>
        <div class="menu" id="menu-mobile"><div class="search-wrapper">
                    <div class="search mobile" id="search-mobile">
                        <input type="text" placeholder=" " id="search-input-mobile">
                        <a href="javascript:void(0);" class="search-button search-toggle" id="search-toggle-mobile" title="搜索">
                            <i class="fas fa-search fa-fw" aria-hidden="true"></i>
                        </a>
                        <a href="javascript:void(0);" class="search-button search-clear" id="search-clear-mobile" title="清空">
                            <i class="fas fa-times-circle fa-fw" aria-hidden="true"></i>
                        </a>
                        <span class="search-button search-loading" id="search-loading-mobile">
                            <i class="fas fa-spinner fa-fw fa-spin" aria-hidden="true"></i>
                        </span>
                    </div>
                    <a href="javascript:void(0);" class="search-cancel" id="search-cancel-mobile">
                        取消
                    </a>
                </div><a class="menu-item" href="/posts/" title="">📜归档</a><a class="menu-item" href="/tags/" title="">🏷️标签</a><a class="menu-item" href="/categories/" title="">📂分类</a><a class="menu-item" href="/about/" title="">⭐关于</a><a href="javascript:void(0);" class="menu-item theme-switch" title="切换主题">
                <i class="fas fa-adjust fa-fw" aria-hidden="true"></i>
            </a></div>
    </div>
</header><div class="search-dropdown desktop">
        <div id="search-dropdown-desktop"></div>
    </div>
    <div class="search-dropdown mobile">
        <div id="search-dropdown-mobile"></div>
    </div><main class="main">
                <div class="container"><div class="toc" id="toc-auto">
            <h2 class="toc-title">目录</h2>
            <div class="toc-content" id="toc-content-auto"></div>
        </div><article class="page single"><h1 class="single-title animate__animated animate__flipInX">EtherCAT从会到不会——封包解析（3）</h1><div class="post-meta">
            <div class="post-meta-line"><span class="post-author"><a href="/" title="Author" rel="author" class="author"><i class="fas fa-user-circle fa-fw" aria-hidden="true"></i>Jacob Chen</a></span>&nbsp;<span class="post-category">收录于 <a href="/categories/%E7%8E%B0%E5%9C%BA%E6%80%BB%E7%BA%BF/"><i class="far fa-folder fa-fw" aria-hidden="true"></i>现场总线</a></span></div>
            <div class="post-meta-line"><i class="far fa-calendar-alt fa-fw" aria-hidden="true"></i>&nbsp;<time datetime="2023-08-27">2023-08-27</time>&nbsp;<i class="fas fa-pencil-alt fa-fw" aria-hidden="true"></i>&nbsp;约 1807 字&nbsp;
                <i class="far fa-clock fa-fw" aria-hidden="true"></i>&nbsp;预计阅读 4 分钟&nbsp;</div>
        </div><div class="details toc" id="toc-static"  data-kept="">
                <div class="details-summary toc-title">
                    <span>目录</span>
                    <span><i class="details-icon fas fa-angle-right" aria-hidden="true"></i></span>
                </div>
                <div class="details-content toc-content" id="toc-content-static"><nav id="TableOfContents">
  <ul>
    <li><a href="#总览">总览</a>
      <ul>
        <li><a href="#ethercat-header">EtherCAT Header</a></li>
        <li><a href="#ethercat-datagram">EtherCAT Datagram</a></li>
        <li><a href="#例子">例子</a></li>
      </ul>
    </li>
    <li><a href="#ethercat-command-typeethercat命令">EtherCAT Command Type（EtherCAT命令）</a></li>
    <li><a href="#ethercat-addressing-modes寻址模式">EtherCAT Addressing Modes（寻址模式）</a>
      <ul>
        <li><a href="#分类">分类</a></li>
        <li><a href="#position-addressauto-increment-address位置寻址">Position Address/Auto Increment Address（位置寻址）</a></li>
        <li><a href="#node-addressconfigured-station-address节点寻址">Node Address/Configured Station Address（节点寻址）</a></li>
        <li><a href="#broadcast广播">Broadcast（广播）</a></li>
        <li><a href="#logical-address逻辑寻址">Logical Address（逻辑寻址）</a></li>
      </ul>
    </li>
    <li><a href="#working-counter">Working Counter</a></li>
  </ul>
</nav></div>
            </div><div class="content" id="content"><!-- # EtherCAT从会到不会——封包解析（3） -->
<blockquote>
<p>本来还想着起什么名字，但是对比起内容，名字什么的一点都不重要。<br/>
最近我又想起要写点什么东西防止最后什么都不剩下。那就从EtherCAT开始吧！</p>
</blockquote>
<h2 id="总览">总览</h2>
<p><img
        class="lazyload"
        src="/svg/loading.min.svg"
        data-src="https://gitee.com/jacobcj/blog-pic/raw/master/blog/EtherCAT-%e5%b0%81%e5%8c%85%e6%9e%b6%e6%9e%84%e6%a6%82%e8%a7%88.png"
        data-srcset="https://gitee.com/jacobcj/blog-pic/raw/master/blog/EtherCAT-%e5%b0%81%e5%8c%85%e6%9e%b6%e6%9e%84%e6%a6%82%e8%a7%88.png, https://gitee.com/jacobcj/blog-pic/raw/master/blog/EtherCAT-%e5%b0%81%e5%8c%85%e6%9e%b6%e6%9e%84%e6%a6%82%e8%a7%88.png 1.5x, https://gitee.com/jacobcj/blog-pic/raw/master/blog/EtherCAT-%e5%b0%81%e5%8c%85%e6%9e%b6%e6%9e%84%e6%a6%82%e8%a7%88.png 2x"
        data-sizes="auto"
        alt="https://gitee.com/jacobcj/blog-pic/raw/master/blog/EtherCAT-封包架构概览.png"
        title="封包架构概览" /></p>
<ol>
<li>EtherCAT 使用标准的IEEE 802.3以太网帧，因此可以使用标准的网络控制器，主站也无需使用特殊的硬件。</li>
<li>EtherCAT 帧的 <strong>EtherType 0x88A4</strong>，以区别于其他以太网帧。因此，EtherCAT 可以与其他以太网协议并行运行。</li>
<li>EtherCAT 不需要 IP协议，但是也可以封装在 UDP/IP 协议中（上图中第2种情况）。</li>
</ol>
<h3 id="ethercat-header">EtherCAT Header</h3>
<p><img
        class="lazyload"
        src="/svg/loading.min.svg"
        data-src="https://gitee.com/jacobcj/blog-pic/raw/master/blog/EtherCAT-EtherCAT_Header.png"
        data-srcset="https://gitee.com/jacobcj/blog-pic/raw/master/blog/EtherCAT-EtherCAT_Header.png, https://gitee.com/jacobcj/blog-pic/raw/master/blog/EtherCAT-EtherCAT_Header.png 1.5x, https://gitee.com/jacobcj/blog-pic/raw/master/blog/EtherCAT-EtherCAT_Header.png 2x"
        data-sizes="auto"
        alt="https://gitee.com/jacobcj/blog-pic/raw/master/blog/EtherCAT-EtherCAT_Header.png"
        title="EtherCAT Header" /></p>
<table>
<thead>
<tr>
<th>字段</th>
<th>数据类型</th>
<th>描述</th>
</tr>
</thead>
<tbody>
<tr>
<td>Length</td>
<td>11 bit</td>
<td>EtherCAT Datagrams 的长度，不包括 FCS（校验）<br/>从站不检查</td>
</tr>
<tr>
<td>Reserved</td>
<td>1 bit</td>
<td>保留，0</td>
</tr>
<tr>
<td>Type</td>
<td>4 bit</td>
<td>协议类型。只有当 <strong>Type = 0x1</strong> 时，从站 ESC 才会执行 EtherCAT Command</td>
</tr>
</tbody>
</table>
<h3 id="ethercat-datagram">EtherCAT Datagram</h3>
<p><img
        class="lazyload"
        src="/svg/loading.min.svg"
        data-src="https://gitee.com/jacobcj/blog-pic/raw/master/blog/EtherCAT-EtherCAT_Datagram.png"
        data-srcset="https://gitee.com/jacobcj/blog-pic/raw/master/blog/EtherCAT-EtherCAT_Datagram.png, https://gitee.com/jacobcj/blog-pic/raw/master/blog/EtherCAT-EtherCAT_Datagram.png 1.5x, https://gitee.com/jacobcj/blog-pic/raw/master/blog/EtherCAT-EtherCAT_Datagram.png 2x"
        data-sizes="auto"
        alt="https://gitee.com/jacobcj/blog-pic/raw/master/blog/EtherCAT-EtherCAT_Datagram.png"
        title="EtherCAT Datagram" /></p>
<table>
<thead>
<tr>
<th>字段</th>
<th>数据类型</th>
<th>描述</th>
</tr>
</thead>
<tbody>
<tr>
<td>Cmd</td>
<td>byte</td>
<td>EtherCAT Command Type（EtherCAT命令）</td>
</tr>
<tr>
<td>Idx</td>
<td>byte</td>
<td>索引。由主站生成，从站用于判断 Datagram 是否重复或者丢失。</td>
</tr>
<tr>
<td>Address</td>
<td>dword</td>
<td>地址数据</td>
</tr>
<tr>
<td>Len</td>
<td>11 bit</td>
<td>该 Datagram 所携带的 Data 部分的大小</td>
</tr>
<tr>
<td>R</td>
<td>3 bit</td>
<td>Reserved，保留</td>
</tr>
<tr>
<td>C</td>
<td>1 bit</td>
<td>Circulating Frame，循环帧。<br/>0：该帧未被循环<br/>1：该帧循环过一次</td>
</tr>
<tr>
<td>M</td>
<td>1 bit</td>
<td>0：（Last）最后一次 EtherCAT datagram <br/>1: （More Follow）后面还有 EtherCAT datagrams</td>
</tr>
<tr>
<td>IRQ</td>
<td>word</td>
<td>将所有从站的 EtherCAT Event Request registers 进行逻辑或（OR）运算</td>
</tr>
<tr>
<td>Data</td>
<td>byte[n]</td>
<td>读取或写入的数据</td>
</tr>
<tr>
<td>WKC</td>
<td>word</td>
<td>Working Counter，工作计数器，Datagram 每被处理一次就自增相应的数值</td>
</tr>
</tbody>
</table>
<h3 id="例子">例子</h3>
<p><img
        class="lazyload"
        src="/svg/loading.min.svg"
        data-src="https://gitee.com/jacobcj/blog-pic/raw/master/blog/EtherCAT-%e5%b0%81%e5%8c%85%e4%be%8b%e5%ad%90.png"
        data-srcset="https://gitee.com/jacobcj/blog-pic/raw/master/blog/EtherCAT-%e5%b0%81%e5%8c%85%e4%be%8b%e5%ad%90.png, https://gitee.com/jacobcj/blog-pic/raw/master/blog/EtherCAT-%e5%b0%81%e5%8c%85%e4%be%8b%e5%ad%90.png 1.5x, https://gitee.com/jacobcj/blog-pic/raw/master/blog/EtherCAT-%e5%b0%81%e5%8c%85%e4%be%8b%e5%ad%90.png 2x"
        data-sizes="auto"
        alt="https://gitee.com/jacobcj/blog-pic/raw/master/blog/EtherCAT-封包例子.png"
        title="封包例子" /></p>
<h2 id="ethercat-command-typeethercat命令">EtherCAT Command Type（EtherCAT命令）</h2>
<table>
    <tr>
        <td>模式</td>
        <td>EtherCAT命令（Cmd值）</td>
        <td>读/写</td>
        <td>描述</td>
        <td>触发条件</td>
        <td>WKC </td>
    </tr>
    <tr>
        <td> 无</td>
        <td>NOP(0)</td>
        <td>无</td>
        <td>没有操作</td>
        <td>无</td>
        <td>0 </td>
    </tr>
    <tr>
        <td rowspan=3>Position Address<br/>位置寻址（顺序寻址）</td>
        <td>APRD(1)</td>
        <td>R</td>
        <td>向从站读取一定长度数据</td>
        <td rowspan=3>ADP=0 </td>
        <td>1 </td>
    </tr>
    <tr>
        <td>APWR(2)</td>
        <td>W</td>
        <td>向从站写入一定长度数据</td>
        <td>1 </td>
    </tr>
    <tr>
        <td>APRW(3)</td>
        <td>RW</td>
        <td>与从站交换数据</td>
        <td>3（1+2）</td>
    </tr>
    <tr>
        <td rowspan=3>Node Address<br/>节点寻址（站号寻址）</td>
        <td>FPRD(4)</td>
        <td>R</td>
        <td>向从站读取一定长度数据</td>
        <td rowspan=3>ADP=conf. station adr. </td>
        <td>1 </td>
    </tr>
    <tr>
        <td>FPWR(5)</td>
        <td>W</td>
        <td>向从站写入一定长度数据</td>
        <td>1 </td>
    </tr>
    <tr>
        <td>FPRW(6)</td>
        <td>RW</td>
        <td>与从站交换数据</td>
        <td>3（1+2）</td>
    </tr>
    <tr>
        <td rowspan=3>Broadcast<br/>广播</td>
        <td>BRD(7)</td>
        <td>R</td>
        <td>主站向所有从站的内存区读取数据并做逻辑或（OR）操作</td>
        <td rowspan=3>all </td>
        <td rowspan=8>与执行到该指令的从站个数相关 </td>
    </tr>
    <tr>
        <td>BWR(8)</td>
        <td>W</td>
        <td>主站广播写入所有从站 </td>
    </tr>
    <tr>
        <td>BRW(9)</td>
        <td>RW</td>
        <td>主站与所有从站交换数据，对读取的数据做逻辑或（OR）操作 </td>
    </tr>
    <tr>
        <td rowspan=3>Logical Address<br/>逻辑寻址</td>
        <td>LRD(10)</td>
        <td>R</td>
        <td>读取一定长度数据 </td>
        <td rowspan=3>FMMU</td>
    </tr>
    <tr>
        <td>LWR(11)</td>
        <td>W</td>
        <td>写入一定长度数据 </td>
    </tr>
    <tr>
        <td>LRW(12)</td>
        <td>RW</td>
        <td>与从站交换数据 </td>
    </tr>
    <tr>
        <td>Position Address<br/>位置寻址（顺序寻址）</td>
        <td>ARMW(13)</td>
        <td>RW</td>
        <td>读取从站数据，并写入之后所有从站的相同地址</td>
        <td>Read: ADP=0<br/>Write: ADP≠0 </td>
    </tr>
    <tr>
        <td>Node Address<br/>节点寻址（站号寻址）</td>
        <td>FRMW(14) </td>
        <td>RW</td>
        <td>读取从站数据，并写入之后所有从站的相同地址</td>
        <td>Read: ADP= conf. station adr.<br/>Write: ADP≠ conf. station adr.</td>
    </tr>
</table>
<h2 id="ethercat-addressing-modes寻址模式">EtherCAT Addressing Modes（寻址模式）</h2>
<p><img
        class="lazyload"
        src="/svg/loading.min.svg"
        data-src="https://gitee.com/jacobcj/blog-pic/raw/master/blog/EtherCAT-%e5%af%bb%e5%9d%80%e6%96%b9%e5%bc%8f.png"
        data-srcset="https://gitee.com/jacobcj/blog-pic/raw/master/blog/EtherCAT-%e5%af%bb%e5%9d%80%e6%96%b9%e5%bc%8f.png, https://gitee.com/jacobcj/blog-pic/raw/master/blog/EtherCAT-%e5%af%bb%e5%9d%80%e6%96%b9%e5%bc%8f.png 1.5x, https://gitee.com/jacobcj/blog-pic/raw/master/blog/EtherCAT-%e5%af%bb%e5%9d%80%e6%96%b9%e5%bc%8f.png 2x"
        data-sizes="auto"
        alt="https://gitee.com/jacobcj/blog-pic/raw/master/blog/EtherCAT-寻址方式.png"
        title="寻址方式" /></p>
<p>由于 Address 数据的定义与寻址方式相关，这就导致了执行不同的 EtherCAT Command（EtherCAT命令）时，解析 Address 的方式就会有所不同。</p>
<h3 id="分类">分类</h3>
<table>
    <tr>
        <td colspan=2 style="text-align:center"> 寻址模式</td>
        <td>字段</td>
        <td>数据类型</td>
        <td>描述</td>
    </tr>
    <tr>
        <td rowspan=6>Device Addressing<br/>设备寻址</td>
        <td rowspan=2>Position Addressing<br/>位置寻址</td>
        <td>Position</td>
        <td>WORD</td>
        <td>Each slave increments Position.  Slave is addressed if Position = 0. </td>
    </tr>
    <tr>
        <td>Offset</td>
        <td>WORD</td>
        <td>Local register or memory address of the ESC  </td>
    </tr>
    <tr>
        <td rowspan=2>Node Addressing<br/>节点寻址</td>
        <td>Address</td>
        <td>WORD</td>
        <td>Slave is addressed if Address matches Configured Station Address or Configured Station Alias (if enabled).  </td>
    </tr>
    <tr>
        <td>Offset</td>
        <td>WORD</td>
        <td>Local register or memory address of the ESC </td>
    </tr>
    <tr>
        <td rowspan=2>Broadcast<br/>广播</td>
        <td>Position</td>
        <td>WORD </td>
        <td>Each slave increments Position (not used for addressing) </td>
    </tr>
    <tr>
        <td>Offset</td>
        <td>WORD </td>
        <td>Local register or memory address of the ESC </td>
    </tr>
    <tr>
        <td colspan=2>Logical Addressing<br/>逻辑寻址</td>
        <td>Address</td>
        <td>DWORD</td>
        <td>Logical Address (configured by FMMUs)  Slave is addressed if FMMU configuration matches Address. </td>
    </tr>
</table>
<h3 id="position-addressauto-increment-address位置寻址">Position Address/Auto Increment Address（位置寻址）</h3>
<ul>
<li>主站会根据要访问的从站对象，将 Address 中的 Position 设置为 0 或者 负值。</li>
<li>Datagram <strong>每经过一个从站，Position + 1</strong>。</li>
<li>从站读取 Position 的值，如果等于0，从站将在接收时执行相应的命令。</li>
<li>位置寻址应该<strong>只在 EtherCAT 系统启动时用于扫描从站</strong>，以后只偶尔用于检测新连接的从站。</li>
</ul>
<h3 id="node-addressconfigured-station-address节点寻址">Node Address/Configured Station Address（节点寻址）</h3>
<ul>
<li>直接由控制器设定各从站的固定站号，且不能由从站来更改。</li>
<li>与 Position Address（位置寻址）的地址彼此独立，与实体配线顺序无关。</li>
<li>Address 中的 Address 值与配置的从站站号相等时，则从站执行相应命令。</li>
<li>通常<strong>用于对个别和已标识的设备的寄存器访问（如 Mailbox 访问）</strong>。</li>
</ul>
<p>以 Codesys 系统举例，位置寻址、节点寻址的不同</p>
<p><img
        class="lazyload"
        src="/svg/loading.min.svg"
        data-src="https://gitee.com/jacobcj/blog-pic/raw/master/blog/EtherCAT-Codesys%e4%b8%8d%e5%90%8c%e5%af%bb%e5%9d%80%e5%9c%b0%e5%9d%80.png"
        data-srcset="https://gitee.com/jacobcj/blog-pic/raw/master/blog/EtherCAT-Codesys%e4%b8%8d%e5%90%8c%e5%af%bb%e5%9d%80%e5%9c%b0%e5%9d%80.png, https://gitee.com/jacobcj/blog-pic/raw/master/blog/EtherCAT-Codesys%e4%b8%8d%e5%90%8c%e5%af%bb%e5%9d%80%e5%9c%b0%e5%9d%80.png 1.5x, https://gitee.com/jacobcj/blog-pic/raw/master/blog/EtherCAT-Codesys%e4%b8%8d%e5%90%8c%e5%af%bb%e5%9d%80%e5%9c%b0%e5%9d%80.png 2x"
        data-sizes="auto"
        alt="https://gitee.com/jacobcj/blog-pic/raw/master/blog/EtherCAT-Codesys不同寻址地址.png"
        title="不同寻址地址" /></p>
<h3 id="broadcast广播">Broadcast（广播）</h3>
<ul>
<li>每一个 EtherCAT 从站都会执行。</li>
<li>广播寻址一般<strong>用于检查所有从站的状态、初始化从站</strong>等工作。</li>
<li></li>
</ul>
<h3 id="logical-address逻辑寻址">Logical Address（逻辑寻址）</h3>
<ul>
<li>主站会将所有需要读写的数据全部放在同一个逻辑地址空间中（4GB）。</li>
<li>在 EtherCAT 网络启动时，主站会配置好每个从站的 FMMU（现场总线存储器管理单元）。</li>
<li>从站从 FMMU 的配置信息得知，逻辑地址与从站的物理地址之间的映射关系。</li>
<li>逻辑寻址<strong>用于Process Data（PDO）的传输</strong>，通过对空间地址的映射，来提升封包的传输效率。</li>
</ul>
<p><img
        class="lazyload"
        src="/svg/loading.min.svg"
        data-src="https://gitee.com/jacobcj/blog-pic/raw/master/blog/EtherCAT-FMMU.png"
        data-srcset="https://gitee.com/jacobcj/blog-pic/raw/master/blog/EtherCAT-FMMU.png, https://gitee.com/jacobcj/blog-pic/raw/master/blog/EtherCAT-FMMU.png 1.5x, https://gitee.com/jacobcj/blog-pic/raw/master/blog/EtherCAT-FMMU.png 2x"
        data-sizes="auto"
        alt="https://gitee.com/jacobcj/blog-pic/raw/master/blog/EtherCAT-FMMU.png"
        title="FMMU" /></p>
<h2 id="working-counter">Working Counter</h2>
<ul>
<li>每个 EtherCAT Datagram 都以一个16位工作计数器(WKC)结束。</li>
<li>Working Counter 计算这个 EtherCAT Datagram 成功寻址的设备数量（即执行的次数）。</li>
<li>每个Datagram都应该有一个由主站计算的预期 Working Counter 值。主站可以通过比较 Working Counter 和期望值来检查 EtherCAT Datagram 的有效处理。</li>
</ul>
<table>
    <tr>
        <td>命令</td>
        <td>类型</td>
        <td>自增值</td>
    </tr>
    <tr>
        <td rowspan=2>Read command</td>
        <td>No success</td>
        <td>+0</td>
    </tr>
    <tr>
        <td>Successful read</td>
        <td>+1</td>
    </tr>
    <tr>
        <td rowspan=2>Write command</td>
        <td>No success</td>
        <td>+0</td>
    </tr>
    <tr>
        <td>Successful write</td>
        <td>+1</td>
    </tr>
    <tr>
        <td rowspan=4>ReadWrite command</td>
        <td>No success</td>
        <td>+0</td>
    </tr>
    <tr>
        <td>Successful read</td>
        <td>+1</td>
    </tr>
    <tr>
        <td>Successful write</td>
        <td>+2</td>
    </tr>
    <tr>
        <td>Successful read and write</td>
        <td>+3</td>
    </tr>
</table>
<p>参考资料：
ET1100datasheet</p>
</div><div class="post-footer" id="post-footer">
    <div class="post-info">
        <div class="post-info-line">
            <div class="post-info-mod">
                <span>更新于 2023-08-27</span>
            </div></div>
        <div class="post-info-line">
            <div class="post-info-md"><span>
                            <a class="link-to-markdown" href="/ethercat_03protocol/index.md" target="_blank">阅读原始文档</a>
                        </span></div>
            <div class="post-info-share">
                <span></span>
            </div>
        </div>
    </div>

    <div class="post-info-more">
        <section class="post-tags"><i class="fas fa-tags fa-fw" aria-hidden="true"></i>&nbsp;<a href="/tags/ethercat/">EtherCAT</a></section>
        <section>
            <span><a href="javascript:void(0);" onclick="window.history.back();">返回</a></span>&nbsp;|&nbsp;<span><a href="/">主页</a></span>
        </section>
    </div>

    <div class="post-nav"><a href="/redis_01pubsub/" class="prev" rel="prev" title="Redis学习笔记——订阅发布"><i class="fas fa-angle-left fa-fw" aria-hidden="true"></i>Redis学习笔记——订阅发布</a>
            <a href="/ethercat_04esi_0d/" class="next" rel="next" title="EtherCAT从会到不会——ESI文档、对象字典（4）">EtherCAT从会到不会——ESI文档、对象字典（4）<i class="fas fa-angle-right fa-fw" aria-hidden="true"></i></a></div>
</div>
</article></div>
            </main><footer class="footer">
        <div class="footer-container"><div class="footer-line">由 <a href="https://gohugo.io/" target="_blank" rel="noopener noreffer" title="Hugo 0.115.4">Hugo</a> 强力驱动 | 主题 - <a href="https://github.com/dillonzq/LoveIt" target="_blank" rel="noopener noreffer" title="LoveIt 0.2.11"><i class="far fa-kiss-wink-heart fa-fw" aria-hidden="true"></i> LoveIt</a>
                </div><div class="footer-line" itemscope itemtype="http://schema.org/CreativeWork"><i class="far fa-copyright fa-fw" aria-hidden="true"></i><span itemprop="copyrightYear">2023 - 2024</span><span class="author" itemprop="copyrightHolder">&nbsp;<a href="/" target="_blank">Jacob Chen</a></span>&nbsp;|&nbsp;<span class="license"><a rel="license external nofollow noopener noreffer" href="https://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank">CC BY-NC-SA 4.0</a></span></div>
        </div>
    </footer></div>

        <div id="fixed-buttons"><a href="#" id="back-to-top" class="fixed-button" title="回到顶部">
                <i class="fas fa-arrow-up fa-fw" aria-hidden="true"></i>
            </a><a href="#" id="view-comments" class="fixed-button" title="查看评论">
                <i class="fas fa-comment fa-fw" aria-hidden="true"></i>
            </a>
        </div><script type="text/javascript" src="https://cdn.jsdelivr.net/npm/autocomplete.js@0.38.1/dist/autocomplete.min.js"></script><script type="text/javascript" src="https://cdn.jsdelivr.net/npm/lunr@2.3.9/lunr.min.js"></script><script type="text/javascript" src="/lib/lunr/lunr.stemmer.support.min.js"></script><script type="text/javascript" src="/lib/lunr/lunr.zh.min.js"></script><script type="text/javascript" src="https://cdn.jsdelivr.net/npm/lazysizes@5.3.2/lazysizes.min.js"></script><script type="text/javascript" src="https://cdn.jsdelivr.net/npm/clipboard@2.0.11/dist/clipboard.min.js"></script><script type="text/javascript">window.config={"code":{"copyTitle":"复制到剪贴板","maxShownLines":50},"comment":{},"search":{"highlightTag":"em","lunrIndexURL":"/index.json","lunrLanguageCode":"zh","lunrSegmentitURL":"/lib/lunr/lunr.segmentit.js","maxResultLength":10,"noResultsFound":"没有找到结果","snippetLength":30,"type":"lunr"}};</script><script type="text/javascript" src="/js/theme.min.js"></script></body>
</html>
